<template>
  <div>
    <Chart :cdata="cdata"/>
  </div>
</template>

<script>
import Chart from './chart.vue'
import {query12MonthEmission} from "@/api/carbon-manage/data";
import {queryMarketInfo} from "@/api/carbon-manage/trade";

export default {
  data() {
    return {
      cdata: {
        category: [],
        lineData: [],
        barData: [],
        rateData: []
      },
      dataList: [],

    };
  },
  components: {
    Chart,
  },
  mounted() {
    this.setData();
  },
  methods: {
    // 根据自己的业务情况修改
    setData() {
      this.cdata.category = [];
      this.cdata.barData = [];
      queryMarketInfo(0).then(res => {
        for (let i = 0; i < 12; i++) {
          let data = res.data;
          console.log(data)
          this.cdata.category.push(data[i].infoList[0]);
          this.cdata.barData.push(parseFloat(data[i].infoList[3]).toFixed(2))
        }
      })

      // query12MonthEmission().then(res => {
      //   console.log(res)
      //   let data = res.data;
      //   for (let i = 0; i < data.length; i++) {
      //     this.cdata.category.push(data[i].date + '月');
      //     this.cdata.barData.push(data[i].emission.toFixed(2))
      //   }
      // })
    },
  }
};
</script>

<style lang="scss" scoped>
</style>
